package com.linkwedo.saas.project;

import java.sql.Timestamp;
import java.util.Date;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.interceptor.ServletRequestAware;
import org.apache.struts2.interceptor.ServletResponseAware;

import com.linkwedo.saas.domain.Project;
import com.linkwedo.saas.domain.ProjectReview;
import com.linkwedo.saas.users.UserService;
import com.linkwedo.saas.util.excel.ExcelUtil;
import com.opensymphony.xwork2.ActionSupport;
public class DownLoadOnePagePMAction extends ActionSupport implements ServletRequestAware,ServletResponseAware{
	private static final long serialVersionUID = 8190003683775267839L;
	
	private ProjectReviewService projectReviewService;
	private List<ProjectReview> list;
	public List<ProjectReview> getList() {
		return list;
	}

	public void setList(List<ProjectReview> list) {
		this.list = list;
	}	

	public javax.servlet.http.HttpServletRequest getRequest() {
		return request;
	}

	public void setRequest(javax.servlet.http.HttpServletRequest request) {
		this.request = request;
	}

	private javax.servlet.http.HttpServletRequest request;
	private javax.servlet.http.HttpServletResponse response;

	

	public static long getSerialversionuid() {
		return serialVersionUID;
	}
	
	public String execute() throws Exception {
		String projectReviewId = request.getParameter("projectReviewId");
		if(null == projectReviewId || "".equalsIgnoreCase(projectReviewId)){
			return ERROR;
		}
		Integer projectReviewIdValue = Integer.parseInt(projectReviewId);

		ProjectReview projectReview = projectReviewService.getProjectReviewById(projectReviewIdValue);
		String newFile = projectReview.getPath();
		ExcelUtil excelOp = new ExcelUtil();
		//excelOp.generateNewFile(path, newFile, project);
		
		excelOp.respsonseExcel(response, newFile, "test.xls");
//		list=getProjectReviewService().findAll();
//	    return "ok";
		return  null;
	}

	@Override
	public void setServletRequest(HttpServletRequest arg0) {
		// TODO Auto-generated method stub
		this.request = arg0;
		
	}



	public javax.servlet.http.HttpServletResponse getResponse() {
		return response;
	}

	public void setResponse(javax.servlet.http.HttpServletResponse response) {
		this.response = response;
	}

	@Override
	public void setServletResponse(HttpServletResponse response) {
		this.response = response;
		
	}

	public ProjectReviewService getProjectReviewService() {
		return projectReviewService;
	}

	public void setProjectReviewService(ProjectReviewService projectReviewService) {
		this.projectReviewService = projectReviewService;
	}
}
